<!DOCTYPE html>
<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>有贝口腔网-注册</title>
    <meta name="keywords" content="有贝口腔网,口腔网,口腔知识,口腔资讯,口腔问答,口腔诊所,口腔厂家,在线看牙">
    <meta name="description" content="有贝口腔网是一家专注互联网口腔服务网站，为用户提供腔知识,口腔资讯,口腔问答,口腔诊所,诊所入住,口腔厂家,厂家入住,在线看牙等综合服务口腔网站">
    <link rel="stylesheet" href="../static/css/logic/reset.css">
    <link rel="stylesheet" href="../static/css/logic/login.css">
    
<script type="text/javascript">
var basePath ="/";
</script>
<script src="../static/js/jquery-3.js"></script>

    <script src="../static/js/md5.js"></script>
    <script src="../../layui/lay/modules/layer.js"></script>
    <link rel="stylesheet" href="../../layui/css/modules/layer/default/layer.css" id="layuicss-layer">
    
    <script type="text/javascript">
    $(function(){
        function reg() {
       	 var userName=$("#phone").val(); 
   		 var code=$("#code").val();
   		 var pwd=$("#password").val();
   		 var pwd2=$("#passwordtwo").val();
   		 //var nick=$("#nick").val();
   		 if(isBlank(userName)){
       		 alert("请输入手机号/邮箱");
       		 return ;
       	 }
       	 if(isBlank(code)){
       		 alert("请输入验证码");
       		 return ;
       	 }
       	 if(isBlank(pwd)){
       		 alert("请输入密码");
       		 return ;
       	 }
       	 if(isBlank(pwd2)){
       		 alert("请输入确认密码");
       		 return ;
       	 }
       	 if(pwd!=pwd2){
       		 alert("确认密码与输入密码不一致");
       		 return ;
       	 }
   		 var data = {};
   		 data["userName"]=userName; 
   		 data["code"]=code;
   		 data["pwd"]=MD5(pwd); 
   		 //data["nick"]=nick;
   		 $.ajax({
   			type : "POST",
   			url : basePath+"reg?t="+new Date().getTime(),
   			data : data,
   			success : function(data) {
   				if (data.success) {
   					layer.msg("恭喜你，注册成功了，且已登录");
   					//是不是弹窗
   					var isd=$("#isd").val();
   					if(isd==1){//是弹窗
   						layerClose(500,true);
   					}else{
   						//重回进入页面
   						forwardIntoUrl(1000);
   					}
   				} else {
   				 	layer.msg(data.msg);
   				}
   			},  
   		    error: function(XMLHttpRequest, textStatus, errorThrown){  
   		    	alert("链接错误,请联系管理员");
   		    }  
   		});
   	}
       function sendCode(obj){
       	 var userName=$("#phone").val(); 
       	 var rcode=$("#imgcode").val();
       	 if(isBlank(userName)){
       		 alert("请输入手机号/邮箱");
       		 return ;
       	 }
       	 if(isBlank(rcode)){
       		 alert("请输入图形验证码");
       		 return ;
       	 }
       	 var data = {};
   		 data["userName"]=userName;
   		 data["code"]=rcode;
       	 $.post(basePath+"send/code/reg",data,function(data){
       		if (data.success) {
      			 daojishi(90,obj);
      		 }else{ 
      			 layer.msg(data.msg);
      		 }
       	 });
       }
       //reCode();
       $("#codeImg").click(function(){
     		reCode();
      });
       function reCode(){
      	 	$("#codeImg").attr("src",basePath+"common/vcode?r="+new Date());
       }
       
       var phone = new RegExp (/^1\d{10}$/); //手机号码验证
       var youxiang = new RegExp (/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/);  //邮箱验证
        $(".regesit-btn").click(function(){
            var loginPhone = $("#phone").val();
            var imgcode = $("#imgcode").val();
            var checkcode = $("#code").val();
            var password = $("#password").val();
            var passwordtwo = $("#passwordtwo").val();
            if(loginPhone.indexOf('@') < 0&&!phone.test(loginPhone)){
            	layer.msg("请输入正确的手机号/邮箱");
                return false
            }

            if(imgcode == ''){
                layer.msg("请输入图片中的验证码");
                return false
            }

            if(checkcode == ''){
                layer.msg("验证码不能为空");
                return false
            }

            if(password == '' || password.length < 6){
                layer.msg("请输入6~18位密码");
                return false
            }

            if(passwordtwo == '' || passwordtwo.length < 6){
                layer.msg("请再次确认密码");
                return false
            }

            if(password !== passwordtwo){
                layer.msg("两次输入的密码不一致");
                return false
            }

            /* if(!$('#protocol').is(':checked')) {
                layer.msg("请勾选用户协议");
                return false
            } */
            reg();
        })

        function daojishi(seconds,obj){
            if (seconds > 1){
                $(obj).css("background-color","#ccc");
                seconds--;
                $(obj).text(seconds+"s后重新发送").attr("disabled", true);//禁用按钮
                // 定时1秒调用一次
                setTimeout(function(){
                    daojishi(seconds,obj);
                },1000);
            }else{
                $(obj).css("background-color","#1482C8");
                $(obj).text("发送验证码").attr("disabled", false);//启用按钮
            }
        }

        $(".send-btn").click(function(){
        	var loginPhone=$("#phone").val();
            if(loginPhone.indexOf('@') < 0&&!phone.test(loginPhone)){
            	layer.msg("请输入正确的手机号/邮箱");
                return false
            }
            var code = $("#imgcode").val();
            if(code == ''){
                layer.msg("请输入图中验证码");
                return false
            }
          	//发送验证码
            sendCode(this);
        })
    })
    </script>
</head>
<body>
<div class="container">
		<input id="isd" value="" type="hidden">
		<!-- 是否弹窗隐藏 -->
		<div>
        	<h1>Welcome</h1>
        	<h2>欢迎注册有贝口腔网</h2>
        </div>
        <form class="form" onsubmit="return false;">
            <div class="form-top">
                
                <a href="https://www.hasbei.com/login?">登录</a>
                
                <a class="active" href="javascript:;">注册</a>
            </div>
            
            <div class="form-mian">

                <div class="regist">
                    <label>
                        <input type="text" placeholder="请输入手机号/邮箱" id="phone" name="phone">
                    </label>

                    <div class="img-check-code">
                        <label>
                            <input placeholder="请输入图形验证码" id="imgcode" name="imgcode">
                        </label>
                        <img id="codeImg" alt="有贝口腔网" src="../static/image/vcode.png">
                    </div>
                    
                    <div class="num-check-code">
                        <label>
                            <input type="text" placeholder="请输入验证码" id="code" name="code">
                        </label>
                        <button class="send-btn" type="button">发送验证码</button>
                    </div>

                    <label class="login-phone">
                        <input type="password" minlength="6" placeholder="请输入6~18位密码" id="password" name="password">
                    </label>
                    <label class="login-phone">
                        <input type="password" minlength="6" placeholder="请再次确认密码" id="passwordtwo" name="passwordtwo">
                    </label>

                    <input class="sub-btn regesit-btn" type="submit" value="注册">

                </div>
            </div>
			<div class="agree-form-item">
                <!-- <input type="checkbox" id="protocol" name="protocol"> -->
                <div>
                    <label for="protocol"><span>登录/注册即表示你同意</span></label>
                    <a href="https://www.hasbei.com/about/agree" target="_blank">《用户协议》</a>
                    <a href="https://www.hasbei.com/about/privacy" target="_blank">《隐私政策》</a>
                </div>
            </div>

        </form>
    </div>

</body></html>